From 9f1203fa13b2df3157cf650801a796f972b368fb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 30 Sep 2016 13:07:37 -0700 Subject: [PATCH] Test requested --target from source of truth We skip doc tests for any cross compiles (as they don't work) but to detect a cross compile we checked `--target` but forgot to check other locations like `CARGO_BUILD_TARGET` or `[build.target]`. This alters the check to ensure that it verifies from the source of truth whether a cross compilation happened or not. Closes #3143 --- src/cargo/ops/cargo_rustc/compilation.rs | 3 +++ src/cargo/ops/cargo_rustc/mod.rs | 1 + src/cargo/ops/cargo_test.rs | 6 ++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/compilation.rs b/src/cargo/ops/cargo_rustc/compilation.rs index 71263450d..23f0a044f 100644 --- a/src/cargo/ops/cargo_rustc/compilation.rs +++ b/src/cargo/ops/cargo_rustc/compilation.rs @@ -44,6 +44,8 @@ pub struct Compilation<'cfg> { /// Features enabled during this compilation. pub cfgs: HashSet, + pub target: String, + config: &'cfg Config, } @@ -60,6 +62,7 @@ impl<'cfg> Compilation<'cfg> { to_doc_test: Vec::new(), cfgs: HashSet::new(), config: config, + target: String::new(), } } diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 59d1ec57f..7f02b3138 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -159,6 +159,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, cx.compilation.native_dirs.insert(dir.clone()); } } + cx.compilation.target = cx.target_triple().to_string(); Ok(cx.compilation) } diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index 44a51be30..e8f155a34 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -116,10 +116,8 @@ fn run_doc_tests(options: &TestOptions, let config = options.compile_opts.config; // We don't build/rust doctests if target != host - if let Some(target) = options.compile_opts.target { - if try!(config.rustc()).host != target { - return Ok(errors); - } + if try!(config.rustc()).host != compilation.target { + return Ok(errors); } let libs = compilation.to_doc_test.iter().map(|package| { -- 2.30.2